package com.yxy.mapper;

import com.yxy.pojo.entity.RemarkThumbs;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface RemarkThumbsMapper {
    /**
     * 添加点赞（初始化为-1）
     * @param remarkThumbs
     */
    void addThumbs(RemarkThumbs remarkThumbs);

    /**
     * 根据用户id和评论id查询点赞
     * @param userId
     * @param remark
     * @return
     */
    @Select("select * from remark_thumbs where remark_id = #{remarkId} and user_id = #{userId}")
    RemarkThumbs selectByUserIdAndRemarkId(int userId, int remarkId);

    /**
     * 赞或踩或-1
     * @param remarkThumbs
     */
    void updateThumbs(RemarkThumbs remarkThumbs);

    /**
     * 根据评论id删除点赞
     * @param id
     */
    @Delete("delete from remark_thumbs where remark_id = #{remarkId}")
    void deleteThumbsByRemarkId(int remarkId);
}
